Exactly what role to attribute to beauty in mathematics and science is hotly contested, see Philosophy of mathematics.
When developing hypotheses, scientists use beauty and elegance as valuable selective criteria.