Study the two-part inventions of J.S. Bach. Observe the compositional style in terms of the structures of the melodies, the interplay between the hands, and the extent to which the music is idiomatic (natural feeling) to a player's hands and coordination.
Decide what level of piano proficiency you want to write for. Since two-part inventions are a pedagogical tool, think of the sorts of skills and issues pianists at beginning, intermediate, and advanced levels will be working to master as opposed to what skills they already have. Keep these limits in mind as you compose and strive to write an invention that's challenging for the target level and will push players slightly beyond where they are.
Create some melodies and themes. Think about technical features you want your invention to help teach, such as speed and coordination through complex motions of fingers. Write melodies that are both pleasant to listen to and require the development of these techniques.
Write the parts for the two hands at the same time. Since inventions are designed to improve the independence of the hands, you will need to write the parts at the same time in order to balance the interplay between them.
Make the composition increasingly complex as it progresses. Make the opening passages the easiest, perhaps starting with only one hand, then adding two hands and keeping the difficulty level balanced between the two (i.e., if one hand is doing something difficult, the notes for the other hand should be easier). As the piece goes on, it should become more active and complex for both hands.