If matter is just an illusion what is the source of it
If matter is just illusion


I don't think that is Buddhist doctrine. I think that Buddhist doctrine is that we tend to view matter inappropriately or with ignorance.


  what is the origin of it


I'm not sure it has an origin. That might be considered an unanswered question. Several suttas (e.g. this one) mention "inconstruable beginning", saying "A beginning point is not evident".


  how is the matter being created by the conciousness


I'm not sure that matter is created by consciousness.

But "perception" (of matter) is created when consciousness, matter, and sense-organ come into contact (see e.g. here).