Limerick is a comic verse, containing five anapestic (unstressed/unstressed/stressed) lines, in which the first, second, and fifth lines are longer, rhyme together, and follow three metrical feet. The third and fourth lines rhyme together, are shorter, and follow two metrical feet. However, sometimes it may vary, and amphibrachic (unstressed/stressed/unstressed) form can replace anapestic. In fact, it is a bawdy, humorous, or nonsensical verse written in the form of five anapests, with an aabba rhyme scheme. Since it has a special structure and format, it is called fixed or closed form of poetry.
The video below will help you understand better and perhaps write your own limerick.
Here are a few examples of limerick from literature: