Often considered as the last 'encyclopedist', Henri Poincaré died one hundred years ago. If he was a prominent man in 1900 French Society, his heritage is not so clearly recognised, particularly in France. Among his too often misunderstood works is his contribution to the theory of relativity, mainly because it is almost never presented within Poincaré's general approach to science, including his philosophical writings. Our aim is therefore to provide an historical account of the main steps (experimental as well as theoretical) which led Poincaré to contribute to the theory of relativity. Starting from the optical experiments which led to the inconsistency of the classical (Galilean) composition law for velocities to explain light propagation, we introduce the FitzGerald and Lorentz contraction which was viewed as the 'sole hypothesis' to explain the Michelson and Morley experiment. We then show that Poincaré's contribution starts with a discussion of the principles governing the mechanics and was built step by step up to express in all its generality the principle of relativity. Poincaré thus showed the invariance of the Maxwell equations under the Lorentz transformation. In doing so, he also discovered the right composition law for velocities. Poincaré's approach to philosophy is detailed to help the reader to understand what a theory meant to him.