How to add Span before my <a tag only for main menu 1st level items
you have forgotten the '#' before localized_options, title &amp; href. 

function mytheme_menu_link($link) {
  if (empty($link['#localized_options'])) {
    $link['#localized_options'] = array();
  }

  $link['#localized_options']['html'] = TRUE; //let l function know that our link title includes html
  return '&lt;span&gt;'.l($link['#title'], $link['#href'], $link['#localized_options']).'&lt;/span&gt;';
}


for main menue only use theme_menu_link__main_menu($var)