Did you know that the original leprechaun was a sun god? That’s right. The sun god Lugh, the hero and savior of the Tuatha De Danaan in the second battle of Mag Tuireadh, went underground after the Tuatha were defeated by the Milesians (that would be the third battle, if anyone’s counting). Anyway, Lugh was one of those who chose move into the mounds (sidhe) rather than leave this plain entirely for Tir Na Nog.
Lugh became a craftsman in the mounds. His work was greatly prized and he was very busy. Over time the stalwart warrior gave way to a stooped being and Lugh became Luchorpain or “little stooping Lugh”.
His followers, also craftsmen (usually shoemakers), became known as leprechauns. They also developed quite a reputation as tricksters and keepers of hidden treasures. They are often associated with rainbows (made by the sun) and pots of gold (perhaps it’s the similarity to sunlight underground?)
And that’s how a stooping sun god created leprechauns.