Why can fraternal twins be different genders, but identical twins are always the same gender?
Identical twins start life as single zygote but soon the early embryo splits in two parts, each part then develops as an organism. Fraternal twins share the womb but they develop from two separate eggs (getting fertilised by two separate sperms).
Identical twins are monozygotic, the zygote formed by fertilisation of an egg by a sperm. Thus identical twins inherit same chromosomes and genes, i.e. they are genetically absolutely identical. This obviously means that both of them would be of same sex.
Though generally a single egg enters the fallopian tube every menstrual cycle, sometimes multiple eggs may mature and could be available for fertilisation. Such eggs develop into nonidentical, fraternal twins. Genetically such twins are related just like any other sibling.