A contrafact is simply a new melody on an existing chord progression. There are tons of contrafacts and certainly this idea is not housed merely in the world of jazz. I connect this tradition to the development of the blues. As Black Americans developed the blues it was expected that everyone had their own blues to sing. While the harmonic structure had developed into something that could be considered universal, the various blues verses and blues melodies were as varied as the people who sang them. To this day there are countless melodies over the standard 12-bar blues.
However, that is not the specific tradition that the term contrafacts refers to. For that, we have to visit the 1940's and observe how bebop musicians took the chord progression to popular show tunes and turned them into a tool for improvisation, often times with a brand new melody. For example, Charlie Parker's Ornithology is simply a contrafact of How High the Moon. This was done for a variety of reasons, and I have to imagine some of was simple economics. Creating new melodies on existing changes did not require musicians to obtain copy writes.
For our purposes, writing your own contrafact can be used as a strategy to learn a tune. We can look at the specific chords to On the Sunny Side of the Street, and create a new melody which works over those chords, but is something all to your own. You may discover your own resolutions and work out ideas from a compositional standpoint that will inform your choices as an improviser.
It is often said that improvising is simply composing, just without an eraser. So this strategy puts the improviser back in the composers chair, gives them an eraser and challenges them to create melody over the chords. Guaranteed, you will understand the changes, and be able to construct better lines while you improvise after having composed a contrafact on those changes!