It is a key principle of design that elements that are similar are perceived by users to be more closely related than elements that are dissimilar. This principle comes from Gestalt psychology, and while often seeming obvious is important to the way that users interact with objects, helping them simplify and structure the world. A simple matrix with alternative rows of dots and squares, this becomes a set of rows only with the similar elements grouped into holistic lines. In the same way, even complex displays is interpreted as having different areas and groupings depending on the colour, shape or size of different elements and to what degree they appear similar.
Such mental grouping reduces complexity and helps users relate different elements to each other, while a lack of such similarity can make it appear that something is made up of multiple unrelated chunks with no connection to each other. Certain types of similarity have been shown to be more effective in different kinds of designs, with colour being the most powerful cue for grouping elements together, especially when the number of colours is few (the effect decreases as the number of colours increases). Size can also be effective if different sizes are clearly distinguishable, and can have other benefits (e.g., large buttons are easier to see and press). Shape is generally less impactful on the perception of elements, and works best if other elements such as size and colour are consistent.
Similarity is an important component of camouflage, and for animals being able to assume the colour, patterns and shape of the background or even of predators (in the case of the mimic octopus) can be your best defence.
Similarity is an important design tool to help users perceive the relatedness of elements or information, indicated by increased similarity for elements that are most related and using different colours, shapes and sizes for elements that are not related. The strongest groupings occur when the fewest colours and simplest shapes are used, as long as they are distinct enough to be detected.
As in all design work, making things simple and easy for the user is always the best option.
Universal Principles of Design by Lidwell, Holden and Butler
Principles of Gestalt Psychology by Kurt Koffka