The algorithm basically takes the smaller of m and n, and generates min(m, n) + 1 points whose coordinates are of the form (i, min(m,n) - i) for all i from 0 to min(m, n).
Why does this work? We need to prove 2 things here: the constructed set is beautiful and has maximum size.
Consider subsets of all points (x, y), where x and y are integers and 0 <= x <= n and 0 <= y <= m. The maximum size of the subset which is also a beautiful set of points can only be equal or less than min(m, n) + 1.
This can be easily proven by Pigeonhole Principle. If there are more than min(m, n) + 1 points, then we can find 2 points which the same x or y coordinates and thus having integer distance, which cause the set to fail the beautiful condition.
The set of min(m, n) + 1 points of the form (i, min(m,n) - i) for all i from 0 to min(m, n) is a beautiful set of points.
This is also easy to prove. Choose 2 different points from the set, which will be of the form (a, min(m, n) - a) and (b, min(m, n) - b), where a, b are integers, 0 <= a, b <= min(m, n), a not equal to b. The distance between 2 points will be sqrt((a - b)^ 2 + (b - a)^2) = sqrt(2) * abs(a - b), which is not an integer.