Yes, you are free to leave the airport. Simply follow the signs for arrivals / domestic flights, go through passports and customs and exit into Japan. On the immigration form, put "0 days" in the "expected length of stay" box. You may be asked why your stay is so short---just be honest, you have a long layover and want to go into the city. Nothing unusual about this at all.
Your bag will not be delivered to you in Osaka, it will be stored ready for your onward flight. Exiting the airport does not change what happens to your bag.
When you return to the airport, if you do not have your onward boarding pass yet, go to a check in desk to get it as normal. If you already have your boarding pass, you can proceed directly to exit control and security.